#include<bits/stdc++.h>
#define int long long
using namespace std;

inline int read(){
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
	return x*f;
}
int T,a,b;
signed main(){
	freopen("sub.in","r",stdin);
	freopen("sub.out","w",stdout);
	T=read();
	while(T--){
		a=read(),b=read();
		if(a>b) swap(a,b);
		if(a==0||b==0){
			puts("0");
			continue;
		}
		if(a>0&&b>0){
			puts("0");
			continue;			
		}
		else if(a<0&&b>0){
			a=-a;
			int ans=min(abs(a-b),min(abs(a),abs(b)));
			printf("%lld\n",ans);
		}
		else{
			puts("0");
			continue;
		}
	}
	return 0;
}